<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* 
*/
class Merchandiser extends CI_Controller
{
	
	public function __construct()
	{
		parent::__construct();
		$this->load->library('session');
		$this->load->model('mglobal');
		$this->load->model('mmaster');
		$this->load->model('mmerchandiser');
		// s$this->load->library("enc");  // encription module create by alfin.akhret@gmail.com
		$this->is_logged_in();
	}

	public function index() {
		$template = 'shell/smooth';
		$data['main_view'] = 'merchandiser/index';
		$this->load->view($template, $data);
	}
	function is_logged_in() {
		$is_logged_in = $this->session->userdata('is_logged_in');
		if (!isset($is_logged_in) || $is_logged_in != true) {
			redirect(base_url() . 'index.php/login');
		}

	}

	function effective_call(){
		$template = 'shell/smooth';
		$cluster_id = $this->mglobal->user_cluster($this->session->userdata('username'));
		$data['sales'] 		 = $this->mglobal->get_sales($cluster_id, array(6) );// merchandiser Select value
		$data['main_view'] = 'merchandiser/effective_call';
		$this->load->view($template, $data);

	}

	function target_call(){

		$template = 'shell/smooth';
		$cluster_id = $this->mglobal->user_cluster($this->session->userdata('username'));
		$data['sales'] 		 = $this->mglobal->get_sales($cluster_id, array(6) );// merchandiser Select value
		$data['main_view'] = 'merchandiser/target_call';
		$this->load->view($template, $data);

	}

	function search(){
		$date = $this->input->post('date');
		$merchan_id = $this->input->post('merchan_id');
		$cluster_id = $this->mglobal->user_cluster($this->session->userdata('username'));
		$row = $this->input->post('row');
		// print_r($encode);
		$encode = $this->mmerchandiser->getOutlet($date, $merchan_id, $cluster_id, $row);
		// print_r($encode);
		echo json_encode($encode);
	}


	function search_outletVisits(){
		$date = $this->input->post('date');
		$merchan_id = $this->input->post('merchan_id');
		$cluster_id = $this->mglobal->user_cluster($this->session->userdata('username'));
		$row = $this->input->post('row');
		$encode = $this->mmerchandiser->getOutletVisits($date, $merchan_id, $cluster_id, $row);

		echo json_encode($encode);
	

	}

	function search_(){

		$date = $this->input->post('date');
		$merchan_id = $this->input->post('merchan_id');
		$cluster_id = $this->mglobal->user_cluster($this->session->userdata('username'));
		$id = $this->input->post('id');
		$row = $this->input->post('row');
		$encode = $this->mmerchandiser->getOutlets_($date, $merchan_id, $cluster_id, $id, $row);

		echo json_encode($encode);
	}
	/*
	function search_fullOutlets(){

		$date = $this->input->post('date');
		$merchan_id = $this->input->post('merchan_id');
		$cluster_id = $this->mglobal->user_cluster($this->session->userdata('username'));

		$encode = $this->mmerchandiser->getFullOutlets($date, $merchan_id, $cluster_id);

		echo json_encode($encode);
	}

	function search_POSM(){
		$date = $this->input->post('date');
		$merchan_id = $this->input->post('merchan_id');
		$cluster_id = $this->mglobal->user_cluster($this->session->userdata('username'));

		$encode = $this->mmerchandiser->getPOSM($date, $merchan_id, $cluster_id);
		echo json_encode($encode);

	}

	function search_Etalse(){
		$date = $this->input->post('date');
		$merchan_id = $this->input->post('merchan_id');
		$cluster_id = $this->mglobal->user_cluster($this->session->userdata('username'));

		$encode = $this->mmerchandiser->getEtalase($date, $merchan_id, $cluster_id);
		echo json_encode($encode);
		
	}
	*/
	/* End of file merchandiser.php */
	/* Location: ./application/controllers/merchandiser.php */

}
